#include "CrowdSim.h"

CrowdSim::CrowdSim()
{
}

CrowdSim::~CrowdSim()
{
}

void CrowdSim::createCamera(void)
{
	// Create the camera
	mCamera = mSceneMgr->createCamera("PlayerCam");

	// Position it at 500 in Z direction
	mCamera->setPosition(Vector3(0,18,70));
	// Look back along -Z
	mCamera->lookAt(Vector3(0,0,-300));
	mCamera->setNearClipDistance(5);
}


bool CrowdSim::configure(void)
{
	// Show the configuration dialog and initialise the system
	// You can skip this and use root.restoreConfig() to load configuration
	// settings if you were sure there are valid ones saved in ogre.cfg
	if(mRoot->showConfigDialog())
	{
		// If returned true, user clicked OK so initialise
		// Here we choose to let the system create a default rendering window by passing 'true'
		mWindow = mRoot->initialise(true);
		// Let's add a nice window icon

		return true;
	}
	else
	{
		return false;
	}
}


// Just override the mandatory create scene method
void CrowdSim::createScene(void)
{
	// Set ambient light
	mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));

	// Create a light
	Light* l = mSceneMgr->createLight("MainLight");
	l->setPosition(20,80,50);
}

// Create new frame listener
void CrowdSim::createFrameListener(void)
{
	mFrameListener= new CrowdSimFrameListener( mSceneMgr, 
		mWindow, 
		mCamera,
		Vector3(0,-9.81,0), // gravity vector for Bullet
		AxisAlignedBox (Ogre::Vector3 (-10000, -10000, -10000), //aligned box for Bullet
		Ogre::Vector3 (10000,  10000,  10000)));
	mRoot->addFrameListener(mFrameListener);
}